﻿CREATE TABLE [dbo].[Image]
(
	[Id] BIGINT NOT NULL PRIMARY KEY IDENTITY(1,1),
	[UserId] BIGINT NOT NULL,
	[FolderId] BIGINT NOT NULL,
	[Name] NVARCHAR(500) NOT NULL,
	[FileType] NVARCHAR(50) NOT NULL,
	[Size] BIGINT NOT NULL,
	[IsPrivate] BIT NOT NULL,
	[IsFolderPrivate] BIT NOT NULL DEFAULT(0),
	[StatusId] SMALLINT NOT NULL, 
    [Uploaded] DATETIME NOT NULL DEFAULT (GETDATE()), 
    CONSTRAINT [FK_Image_User] FOREIGN KEY ([UserId]) REFERENCES [dbo].[User] ([Id]) ON DELETE CASCADE ON UPDATE NO ACTION,
	CONSTRAINT [FK_Image_Folder] FOREIGN KEY ([FolderId]) REFERENCES [dbo].[Folder] ([Id]) ON DELETE CASCADE ON UPDATE NO ACTION,
	CONSTRAINT [UQ_Image_Name] UNIQUE ([UserId], [FolderId], [Name])
)
